const p1 = new Promise((resolve, reject) => {
  // resolve(1)
  reject(1)
})

p1.then(value => {
  // 返回值为2, 是一个非promise对象. 则then()返回的promise对象状态为resolved, 值为2
  // return 2
  // 不显式写return语句, 返回值为undefined, 新promise的resolved值为undefined
  // console.log('onResolved01()', value)

  // return Promise.resolve(3)   // 返回值为一个Promise实例对象, 且状态为resolve
  // return Promise.reject(4)    // 返回值为一个Promise实例对象, 且状态为reject
  throw 5   // 手动抛出异常, 新的promise变为rejected, reason为抛出异常
}, reason => {
  console.log('onRejected01()', reason)
}).then(value => {
  console.log('onResolved02()', value)
}, reason => {
  console.log('onRejected02()', reason)
})


const p2 = Promise.resolve(Promise.resolve(3));

p2.then((res) => {
  console.log(res)
})
